﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MisClient
{
    public partial class FrmCentral : BaseForm
    {

        //统计类型一编码维护
        private FrmType1 frmType1;

        //统计类型二编码维护
        private FrmType2 frmType2;

        //统计类型三编码维护
        private FrmType3 frmType3;

        //部门信息维护
        private FrmDepart frmDepart;

        //库位信息维护
        private FrmArea frmArea;

        //支付工具编码维护
        private FrmCard frmCard;

        //客户结算周期
        private FrmDayJs frmDayJs;

        //客户结算类型
        private FrmFkType frmFkType;

        //供应商进货类型
        private FrmJHType frmJHType;

        //包装单位
        private FrmUnit frmUnit;

        //钱款用途编码
        private FrmYt frmYt;

        //客户分店代码设置
        private FrmCusShop frmCusShop;
        
        //客户部门代码设置
        private FrmCusDep frmCusDep;

        //客户档案管理
        private FrmCustomer frmCustomer;

        //退货出库录入界面
        private FrmRacf frmRacf;

        //移库单录入界面
        private FrmMvRacf frmMvRacf;
        
        //进货入库录入界面
        private FrmBacf frmBacf;

        //批发销售录入界面
        private FrmWholesale frmWholesale;

        //批发销售录入界面
        private FrmDocumentPrint frmDocumentPrint;
        
        //仓库提货确认录入界面
        private FrmPickUpGoods frmPickUpGoods;
      
          //仓库提货确认有数量差异录入界面
        private FrmPickUp frmPickUp;

        //开发票录入界面
        private FrmInvoice frmInvoice;

        //开发票.特殊录入界面
        private FrmInvoiceSpecial frmInvoiceSpecial;
       
        //开发票.取消录入界面
        private FrmInvoiceInvalid frmInvoiceInvalid;
        
        //到款确认按提单号录入界面
        private FrmConfirmMoney1 frmConfirmMoney1;

        //到款确认按提单号录入界面
        private FrmConfirmMoney3 frmConfirmMoney3;
        
        //废弃发票按发票号录入界面
        private FrmConfirmMoney2 frmConfirmMoney2;

        //供应商档案录入界面
        private FrmSupply frmSupply;
        
        //商品代码维护界面
        private FrmGoods frmGoods;

        //批销业务进程查询
        private FrmVolumeBusiness frmVolumeBusiness;

        //单据结算情况查询
        private FrmDocuments frmDocuments;

        //备查薄查询
        private FrmRecordation frmRecordation;

        //对帐单统计
        private FrmStatement frmStatement;

        //销售查询
        private FrmSalesEnquiries frmSalesEnquiries;

        //销售统计
        private FrmSalesStatistics frmSalesStatistics;

        //销售排行榜统计
        private FrmSalesRanking frmSalesRanking;

        //进货查询
        private FrmPurchaseEnquiries frmPurchaseEnquiries;

        //进货统计
        private FrmPurchaseStatistics frmPurchaseStatistics;

        //退货查询
        private FrmReturnEnquiries frmReturnEnquiries;

        //退货统计
        private FrmReturnStatistics frmReturnStatistics;

        //进退货查询
        private FrmJinReturnsEnquiries frmJinReturnsEnquiries;

        //无销售商品库存查询
        private FrmUnsalableGoods frmUnsalableGoods;

        //库存查询
        private FrmStockEnquiries frmStockEnquiries;

        //库存统计
        private FrmStockStatistics frmStockStatistics;

        //变价单录入
        private FrmVariablePrice frmVariablePrice;

        //商品定价查询
        private FrmInqGoodsCus frmInqGoodsCus;


        //商品售价设置
        private FrmGoodsPrice frmGoodsPrice;

        public FrmCentral()
        {
            InitializeComponent();
            FrmLogin fl = new FrmLogin();
            fl.ShowDialog(this);
        }

        private void FrmCentral_Load(object sender, EventArgs e)
        {
            //this.Hide();
        }

        private void Type1ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmType1 != null)
                frmType1.Dispose();
            frmType1 = new FrmType1();
            frmType1.MdiParent = this;
            frmType1.Show();
        }

        private void Type2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmType2 != null)
                frmType2.Dispose();
            frmType2 = new FrmType2();
            frmType2.MdiParent = this;
            frmType2.Show();
        }

        private void Type3ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmType3 != null)
                frmType3.Dispose();
            frmType3 = new FrmType3();
            frmType3.MdiParent = this;
            frmType3.Show();
        }

        private void departToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmDepart != null)
                frmDepart.Dispose();
            frmDepart = new FrmDepart();
            frmDepart.MdiParent = this;
            frmDepart.Show();
        }

        private void KwToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmArea != null)
                frmArea.Dispose();
            frmArea = new FrmArea();
            frmArea.MdiParent = this;
            frmArea.Show();
        }

        private void ZfToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmCard != null)
                frmCard.Dispose();
            frmCard = new FrmCard();
            frmCard.MdiParent = this;
            frmCard.Show();
        }

        private void KhjsZqToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmDayJs != null)
                frmDayJs.Dispose();
            frmDayJs = new FrmDayJs();
            frmDayJs.MdiParent = this;
            frmDayJs.Show();
        }

        private void FkTypeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmFkType != null)
                frmFkType.Dispose();
            frmFkType = new FrmFkType();
            frmFkType.MdiParent = this;
            frmFkType.Show();
        }

        private void JHTypeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmJHType != null)
                frmJHType.Dispose();
            frmJHType = new FrmJHType();
            frmJHType.MdiParent = this;
            frmJHType.Show();
        }

        private void UnitToolStripMenuItem_Click(object sender, EventArgs e)
        {

            if (frmUnit != null)
                frmUnit.Dispose();
            frmUnit = new FrmUnit();
            frmUnit.MdiParent = this;
            frmUnit.Show();
        }

        private void YtToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmYt != null)
                frmYt.Dispose();
            frmYt = new FrmYt();
            frmYt.MdiParent = this;
            frmYt.Show();
        }

        private void CusShopToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmCusShop != null)
                frmCusShop.Dispose();
            frmCusShop = new FrmCusShop();
            frmCusShop.MdiParent = this;
            frmCusShop.Show();
        }

        private void CusDepToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmCusDep != null)
                frmCusDep.Dispose();
            frmCusDep = new FrmCusDep();
            frmCusDep.MdiParent = this;
            frmCusDep.Show();
        }

        private void RacfToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmRacf != null)
                frmRacf.Dispose();
            frmRacf = new FrmRacf();
            frmRacf.MdiParent = this;
            frmRacf.Show();
        }

        private void BacfToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmBacf != null)
                frmBacf.Dispose();
            frmBacf = new FrmBacf();
            frmBacf.MdiParent = this;
            frmBacf.Show();
        }

        private void MvRacfToolStripMenuItem_Click(object sender, EventArgs e)
        {

            if (frmMvRacf != null)
                frmMvRacf.Dispose();
            frmMvRacf = new FrmMvRacf();
            frmMvRacf.MdiParent = this;
            frmMvRacf.Show();
        }

        private void WholesaleToolStripMenuItem1_Click(object sender, EventArgs e)
        {

            if (frmWholesale != null)
                frmWholesale.Dispose();
            frmWholesale = new FrmWholesale();
            frmWholesale.MdiParent = this;
            frmWholesale.Show();
        }

        private void PickUpGoodsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmPickUpGoods != null)
                frmPickUpGoods.Dispose();
            frmPickUpGoods = new FrmPickUpGoods();
            frmPickUpGoods.MdiParent = this;
            frmPickUpGoods.Show();
        }

        private void PickUpToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (frmPickUp != null)
                frmPickUp.Dispose();
            frmPickUp = new FrmPickUp();
            frmPickUp.MdiParent = this;
            frmPickUp.Show();
        }

        private void InvoiceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmInvoice != null)
                frmInvoice.Dispose();
            frmInvoice = new FrmInvoice();
            frmInvoice.MdiParent = this;
            frmInvoice.Show();
        }

        private void InvoiceSpecialToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmInvoiceSpecial != null)
                frmInvoiceSpecial.Dispose();
            frmInvoiceSpecial = new FrmInvoiceSpecial();
            frmInvoiceSpecial.MdiParent = this;
            frmInvoiceSpecial.Show();
        }

        private void InvoiceInvalidToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmInvoiceInvalid != null)
                frmInvoiceInvalid.Dispose();
            frmInvoiceInvalid = new FrmInvoiceInvalid();
            frmInvoiceInvalid.MdiParent = this;
            frmInvoiceInvalid.Show();
        }

        private void ConfirmMoney2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmConfirmMoney3 != null)
                frmConfirmMoney3.Dispose();
            frmConfirmMoney3 = new FrmConfirmMoney3();
            frmConfirmMoney3.MdiParent = this;
            frmConfirmMoney3.Show();
        }

        private void ConfirmMoney1ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmConfirmMoney1 != null)
                frmConfirmMoney1.Dispose();
            frmConfirmMoney1 = new FrmConfirmMoney1();
            frmConfirmMoney1.MdiParent = this;
            frmConfirmMoney1.Show();
        }

        private void SupplyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmSupply != null)
                frmSupply.Dispose();
            frmSupply = new FrmSupply();
            frmSupply.MdiParent = this;
            frmSupply.Show();
        }

        private void GoodsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmGoods != null)
                frmGoods.Dispose();
            frmGoods = new FrmGoods();
            frmGoods.MdiParent = this;
            frmGoods.Show();
        }

        private void DocumentPrintToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmDocumentPrint != null)
                frmDocumentPrint.Dispose();
            frmDocumentPrint = new FrmDocumentPrint();
            frmDocumentPrint.MdiParent = this;
            frmDocumentPrint.Show();
        }

        private void WholesaleToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            if (frmWholesale != null)
                frmWholesale.Dispose();
            frmWholesale = new FrmWholesale(true);
            frmWholesale.MdiParent = this;
            frmWholesale.Show();
        }

        private void VolumeBusinessToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmVolumeBusiness != null)
                frmVolumeBusiness.Dispose();
            frmVolumeBusiness = new FrmVolumeBusiness();
            frmVolumeBusiness.MdiParent = this;
            frmVolumeBusiness.Show();
        }

        private void DocumentsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmDocuments != null)
                frmDocuments.Dispose();
            frmDocuments = new FrmDocuments();
            frmDocuments.MdiParent = this;
            frmDocuments.Show();
        }

        private void RecordationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmRecordation != null)
                frmRecordation.Dispose();
            frmRecordation = new FrmRecordation();
            frmRecordation.MdiParent = this;
            frmRecordation.Show();
        }

        private void StatementToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if ("0000".Equals(accountUser.UserCode) || "1111".Equals(accountUser.UserCode) || "9999".Equals(accountUser.UserCode) || "0046".Equals(accountUser.UserCode) || "0047".Equals(accountUser.UserCode))
            {
                if (frmStatement != null)
                    frmStatement.Dispose();
                frmStatement = new FrmStatement();
                frmStatement.MdiParent = this;
                frmStatement.Show();
            }
            else
            {
                MessageBox.Show("对帐单请到电脑科做！", "信息窗", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
        }

        private void SalesEnquiriesToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (frmSalesEnquiries != null)
                frmSalesEnquiries.Dispose();
            frmSalesEnquiries = new FrmSalesEnquiries();
            frmSalesEnquiries.MdiParent = this;
            frmSalesEnquiries.Show();
        }

        private void SalesStatisticsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmSalesStatistics != null)
                frmSalesStatistics.Dispose();
            frmSalesStatistics = new FrmSalesStatistics();
            frmSalesStatistics.MdiParent = this;
            frmSalesStatistics.Show();
        }

        private void SalesRankingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmSalesRanking != null)
                frmSalesRanking.Dispose();
            frmSalesRanking = new FrmSalesRanking();
            frmSalesRanking.MdiParent = this;
            frmSalesRanking.Show();
        }

        private void PurchaseEnquiriesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmPurchaseEnquiries != null)
                frmPurchaseEnquiries.Dispose();
            frmPurchaseEnquiries = new FrmPurchaseEnquiries();
            frmPurchaseEnquiries.MdiParent = this;
            frmPurchaseEnquiries.Show();
        }

        private void PurchaseStatisticsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmPurchaseStatistics != null)
                frmPurchaseStatistics.Dispose();
            frmPurchaseStatistics = new FrmPurchaseStatistics();
            frmPurchaseStatistics.MdiParent = this;
            frmPurchaseStatistics.Show();
        }

        private void ReturnEnquiriesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmReturnEnquiries != null)
                frmReturnEnquiries.Dispose();
            frmReturnEnquiries = new FrmReturnEnquiries();
            frmReturnEnquiries.MdiParent = this;
            frmReturnEnquiries.Show();
            
        }

        private void ReturnStatisticsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmReturnStatistics != null)
                frmReturnStatistics.Dispose();
            frmReturnStatistics = new FrmReturnStatistics();
            frmReturnStatistics.MdiParent = this;
            frmReturnStatistics.Show();
        }

        private void JinReturnsEnquiriesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmJinReturnsEnquiries != null)
                frmJinReturnsEnquiries.Dispose();
            frmJinReturnsEnquiries = new FrmJinReturnsEnquiries();
            frmJinReturnsEnquiries.MdiParent = this;
            frmJinReturnsEnquiries.Show();
        }

        private void UnsalableGoodsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmUnsalableGoods != null)
                frmUnsalableGoods.Dispose();
            frmUnsalableGoods = new FrmUnsalableGoods();
            frmUnsalableGoods.MdiParent = this;
            frmUnsalableGoods.Show();
            
        }

        private void StockEnquiriesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmStockEnquiries != null)
                frmStockEnquiries.Dispose();
            frmStockEnquiries = new FrmStockEnquiries();
            frmStockEnquiries.MdiParent = this;
            frmStockEnquiries.Show();
            
        }

        private void 库存统计ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmStockStatistics != null)
                frmStockStatistics.Dispose();
            frmStockStatistics = new FrmStockStatistics();
            frmStockStatistics.MdiParent = this;
            frmStockStatistics.Show();

        }

        private void VariablePriceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmVariablePrice != null)
                frmVariablePrice.Dispose();
            frmVariablePrice = new FrmVariablePrice();
            frmVariablePrice.MdiParent = this;
            frmVariablePrice.Show();
        }

        private void CustomerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmCustomer != null)
                frmCustomer.Dispose();
            frmCustomer = new FrmCustomer();
            frmCustomer.MdiParent = this;
            frmCustomer.Show();
        }

        private void ConfirmMoney3ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmConfirmMoney2 != null)
                frmConfirmMoney2.Dispose();
            frmConfirmMoney2 = new FrmConfirmMoney2();
            frmConfirmMoney2.MdiParent = this;
            frmConfirmMoney2.Show();
        }

        private void GoodsPriceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmGoodsPrice != null)
                frmGoodsPrice.Dispose();
            frmGoodsPrice = new FrmGoodsPrice();
            frmGoodsPrice.MdiParent = this;
            frmGoodsPrice.Show();
        }

        private void 退出ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void ClearToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form frm in this.MdiChildren)
            {
                frm.Close();
            }
        }

        private void ReLoginToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FrmLogin fl = new FrmLogin();
            fl.ShowDialog(this);
        }

        private void InqGoodsCusToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (frmInqGoodsCus != null)
                frmInqGoodsCus.Dispose();
            frmInqGoodsCus = new FrmInqGoodsCus();
            frmInqGoodsCus.MdiParent = this;
            frmInqGoodsCus.Show();
        }
    }
}
